#include "widget.h"
#include "ui_widget.h"
#include <QTranslator>
#include <QApplication.h>

QTranslator* mTranslator;


Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    mTranslator = new  QTranslator();
}

Widget::~Widget()
{
    delete ui;
}

void Widget::TranslatorUI()
{
    ui->btn_cn->setText(tr("Simplified Chinese"));
    ui->btn_en->setText(tr("English"));
    ui->btn_ru->setText(tr("Russian language"));
    ui->btn_al->setText(tr("Arab"));
    ui->groupBox->setTitle(tr("Text content"));
    ui->lineEdit->setText(tr("I am Chinese!"));

}

void Widget::on_btn_cn_clicked()
{
    mTranslator->load(":/Language_cn.qm");
    qApp->installTranslator( mTranslator );
    TranslatorUI();
}

void Widget::on_btn_en_clicked()
{
    mTranslator->load(":/Language_en.qm");
        qApp->installTranslator( mTranslator );
        TranslatorUI();
}

void Widget::on_btn_ru_clicked()
{
    mTranslator->load(":/Language_ru.qm");
       qApp->installTranslator( mTranslator );
       TranslatorUI();
}

void Widget::on_btn_al_clicked()
{
    mTranslator->load(":/Language_al.qm");
       qApp->installTranslator( mTranslator );
       TranslatorUI();
}
